<?php


abstract class BaseTblMemberCommBackupPeer {

	
	const DATABASE_NAME = 'mgig';

	
	const TABLE_NAME = 'tbl_member_comm_backup';

	
	const CLASS_DEFAULT = 'lib.model.TblMemberCommBackup';

	
	const NUM_COLUMNS = 21;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;


	
	const F_ID = 'tbl_member_comm_backup.F_ID';

	
	const F_DIST_ID = 'tbl_member_comm_backup.F_DIST_ID';

	
	const F_FROM_DIST_ID = 'tbl_member_comm_backup.F_FROM_DIST_ID';

	
	const F_TYPE = 'tbl_member_comm_backup.F_TYPE';

	
	const F_VOLUME_TYPE = 'tbl_member_comm_backup.F_VOLUME_TYPE';

	
	const F_CPS = 'tbl_member_comm_backup.F_CPS';

	
	const F_AMOUNT = 'tbl_member_comm_backup.F_AMOUNT';

	
	const F_AMOUNT2 = 'tbl_member_comm_backup.F_AMOUNT2';

	
	const F_PERCENT = 'tbl_member_comm_backup.F_PERCENT';

	
	const F_PERCENT2 = 'tbl_member_comm_backup.F_PERCENT2';

	
	const F_LEG1_ID = 'tbl_member_comm_backup.F_LEG1_ID';

	
	const F_LEG1_AMOUNT = 'tbl_member_comm_backup.F_LEG1_AMOUNT';

	
	const F_LEG2_ID = 'tbl_member_comm_backup.F_LEG2_ID';

	
	const F_LEG2_AMOUNT = 'tbl_member_comm_backup.F_LEG2_AMOUNT';

	
	const F_PAIRED_UNIT = 'tbl_member_comm_backup.F_PAIRED_UNIT';

	
	const F_LEVEL = 'tbl_member_comm_backup.F_LEVEL';

	
	const F_STATUS = 'tbl_member_comm_backup.F_STATUS';

	
	const F_DESCR = 'tbl_member_comm_backup.F_DESCR';

	
	const F_BONUS_DATE = 'tbl_member_comm_backup.F_BONUS_DATE';

	
	const F_DATETIME = 'tbl_member_comm_backup.F_DATETIME';

	
	const ID = 'tbl_member_comm_backup.ID';

	
	private static $phpNameMap = null;


	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('FId', 'FDistId', 'FFromDistId', 'FType', 'FVolumeType', 'FCps', 'FAmount', 'FAmount2', 'FPercent', 'FPercent2', 'FLeg1Id', 'FLeg1Amount', 'FLeg2Id', 'FLeg2Amount', 'FPairedUnit', 'FLevel', 'FStatus', 'FDescr', 'FBonusDate', 'FDatetime', 'Id', ),
		BasePeer::TYPE_COLNAME => array (TblMemberCommBackupPeer::F_ID, TblMemberCommBackupPeer::F_DIST_ID, TblMemberCommBackupPeer::F_FROM_DIST_ID, TblMemberCommBackupPeer::F_TYPE, TblMemberCommBackupPeer::F_VOLUME_TYPE, TblMemberCommBackupPeer::F_CPS, TblMemberCommBackupPeer::F_AMOUNT, TblMemberCommBackupPeer::F_AMOUNT2, TblMemberCommBackupPeer::F_PERCENT, TblMemberCommBackupPeer::F_PERCENT2, TblMemberCommBackupPeer::F_LEG1_ID, TblMemberCommBackupPeer::F_LEG1_AMOUNT, TblMemberCommBackupPeer::F_LEG2_ID, TblMemberCommBackupPeer::F_LEG2_AMOUNT, TblMemberCommBackupPeer::F_PAIRED_UNIT, TblMemberCommBackupPeer::F_LEVEL, TblMemberCommBackupPeer::F_STATUS, TblMemberCommBackupPeer::F_DESCR, TblMemberCommBackupPeer::F_BONUS_DATE, TblMemberCommBackupPeer::F_DATETIME, TblMemberCommBackupPeer::ID, ),
		BasePeer::TYPE_FIELDNAME => array ('f_id', 'f_dist_id', 'f_from_dist_id', 'f_type', 'f_volume_type', 'f_cps', 'f_amount', 'f_amount2', 'f_percent', 'f_percent2', 'f_leg1_id', 'f_leg1_amount', 'f_leg2_id', 'f_leg2_amount', 'f_paired_unit', 'f_level', 'f_status', 'f_descr', 'f_bonus_date', 'f_datetime', 'id', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('FId' => 0, 'FDistId' => 1, 'FFromDistId' => 2, 'FType' => 3, 'FVolumeType' => 4, 'FCps' => 5, 'FAmount' => 6, 'FAmount2' => 7, 'FPercent' => 8, 'FPercent2' => 9, 'FLeg1Id' => 10, 'FLeg1Amount' => 11, 'FLeg2Id' => 12, 'FLeg2Amount' => 13, 'FPairedUnit' => 14, 'FLevel' => 15, 'FStatus' => 16, 'FDescr' => 17, 'FBonusDate' => 18, 'FDatetime' => 19, 'Id' => 20, ),
		BasePeer::TYPE_COLNAME => array (TblMemberCommBackupPeer::F_ID => 0, TblMemberCommBackupPeer::F_DIST_ID => 1, TblMemberCommBackupPeer::F_FROM_DIST_ID => 2, TblMemberCommBackupPeer::F_TYPE => 3, TblMemberCommBackupPeer::F_VOLUME_TYPE => 4, TblMemberCommBackupPeer::F_CPS => 5, TblMemberCommBackupPeer::F_AMOUNT => 6, TblMemberCommBackupPeer::F_AMOUNT2 => 7, TblMemberCommBackupPeer::F_PERCENT => 8, TblMemberCommBackupPeer::F_PERCENT2 => 9, TblMemberCommBackupPeer::F_LEG1_ID => 10, TblMemberCommBackupPeer::F_LEG1_AMOUNT => 11, TblMemberCommBackupPeer::F_LEG2_ID => 12, TblMemberCommBackupPeer::F_LEG2_AMOUNT => 13, TblMemberCommBackupPeer::F_PAIRED_UNIT => 14, TblMemberCommBackupPeer::F_LEVEL => 15, TblMemberCommBackupPeer::F_STATUS => 16, TblMemberCommBackupPeer::F_DESCR => 17, TblMemberCommBackupPeer::F_BONUS_DATE => 18, TblMemberCommBackupPeer::F_DATETIME => 19, TblMemberCommBackupPeer::ID => 20, ),
		BasePeer::TYPE_FIELDNAME => array ('f_id' => 0, 'f_dist_id' => 1, 'f_from_dist_id' => 2, 'f_type' => 3, 'f_volume_type' => 4, 'f_cps' => 5, 'f_amount' => 6, 'f_amount2' => 7, 'f_percent' => 8, 'f_percent2' => 9, 'f_leg1_id' => 10, 'f_leg1_amount' => 11, 'f_leg2_id' => 12, 'f_leg2_amount' => 13, 'f_paired_unit' => 14, 'f_level' => 15, 'f_status' => 16, 'f_descr' => 17, 'f_bonus_date' => 18, 'f_datetime' => 19, 'id' => 20, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, )
	);

	
	public static function getMapBuilder()
	{
		include_once 'lib/model/map/TblMemberCommBackupMapBuilder.php';
		return BasePeer::getMapBuilder('lib.model.map.TblMemberCommBackupMapBuilder');
	}
	
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = TblMemberCommBackupPeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(TblMemberCommBackupPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_ID);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_DIST_ID);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_FROM_DIST_ID);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_TYPE);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_VOLUME_TYPE);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_CPS);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_AMOUNT);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_AMOUNT2);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_PERCENT);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_PERCENT2);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_LEG1_ID);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_LEG1_AMOUNT);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_LEG2_ID);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_LEG2_AMOUNT);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_PAIRED_UNIT);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_LEVEL);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_STATUS);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_DESCR);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_BONUS_DATE);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::F_DATETIME);

		$criteria->addSelectColumn(TblMemberCommBackupPeer::ID);

	}

	const COUNT = 'COUNT(tbl_member_comm_backup.ID)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT tbl_member_comm_backup.ID)';

	
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
		
		$criteria = clone $criteria;

		
		$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(TblMemberCommBackupPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(TblMemberCommBackupPeer::COUNT);
		}

		
		foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = TblMemberCommBackupPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
			
			return 0;
		}
	}
	
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = TblMemberCommBackupPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return TblMemberCommBackupPeer::populateObjects(TblMemberCommBackupPeer::doSelectRS($criteria, $con));
	}
	
	public static function doSelectRS(Criteria $criteria, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			TblMemberCommBackupPeer::addSelectColumns($criteria);
		}

		
		$criteria->setDbName(self::DATABASE_NAME);

		
		
		return BasePeer::doSelect($criteria, $con);
	}
	
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
		
		$cls = TblMemberCommBackupPeer::getOMClass();
		$cls = Propel::import($cls);
		
		while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}
	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return TblMemberCommBackupPeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
		} else {
			$criteria = $values->buildCriteria(); 
		}

		$criteria->remove(TblMemberCommBackupPeer::ID); 


		
		$criteria->setDbName(self::DATABASE_NAME);

		try {
			
			
			$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 

			$comparison = $criteria->getComparison(TblMemberCommBackupPeer::ID);
			$selectCriteria->add(TblMemberCommBackupPeer::ID, $criteria->remove(TblMemberCommBackupPeer::ID), $comparison);

		} else { 
			$criteria = $values->buildCriteria(); 
			$selectCriteria = $values->buildPkeyCriteria(); 
		}

		
		$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; 
		try {
			
			
			$con->begin();
			$affectedRows += BasePeer::doDeleteAll(TblMemberCommBackupPeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(TblMemberCommBackupPeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
		} elseif ($values instanceof TblMemberCommBackup) {

			$criteria = $values->buildPkeyCriteria();
		} else {
			
			$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(TblMemberCommBackupPeer::ID, (array) $values, Criteria::IN);
		}

		
		$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 

		try {
			
			
			$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public static function doValidate(TblMemberCommBackup $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(TblMemberCommBackupPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(TblMemberCommBackupPeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		return BasePeer::doValidate(TblMemberCommBackupPeer::DATABASE_NAME, TblMemberCommBackupPeer::TABLE_NAME, $columns);
	}

	
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(TblMemberCommBackupPeer::DATABASE_NAME);

		$criteria->add(TblMemberCommBackupPeer::ID, $pk);


		$v = TblMemberCommBackupPeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria();
			$criteria->add(TblMemberCommBackupPeer::ID, $pks, Criteria::IN);
			$objs = TblMemberCommBackupPeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 


if (Propel::isInit()) {
	
	
	try {
		BaseTblMemberCommBackupPeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
	
	
	require_once 'lib/model/map/TblMemberCommBackupMapBuilder.php';
	Propel::registerMapBuilder('lib.model.map.TblMemberCommBackupMapBuilder');
}
